import { createRouter, createWebHistory } from 'vue-router';
import { user } from './user';
import { study } from './study';
import { crud } from './crud';

const routes = [
  {
    // path就是地址栏访问路径
    path: '/',
    // component表示path路径对应的页面文件
    component: () => import('../view/Home.vue'),
  },
  {
    path: '/test',
    component: () => import('../view/Test.vue'),
  },
  {
    path: '/news',
    component: () => import('../view/News.vue'),
  },
].concat(user, study, crud);

// 创建router
const router = createRouter({
  // 配置为Hash模式
  history: createWebHistory(import.meta.env.BASE_URL),
  // 配置toures
  routes,
  // 路由跳转时返回顶部
  scrollBehavior() {
    return { top: 0 };
  },
});
export { router };
